From 912e79dbe290d6864acaf85174da9a5b6eec30e1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonas=20=C3=85dahl?= Date: Wed, 18 Nov 2015 11:38:28 +0800 Subject: [PATCH] wayland: Use pointer gestures protocol from wayland-protocols Instead of having our own copy of the pointer gestures XML file, use the one installed by wayland-protocols. Since pointer gestures is an unstable protocol, it went through the unstable protocol naming convention changes, which is reflected in this commit. https://bugzilla.gnome.org/show_bug.cgi?id=758634 --- configure.ac | 4 +- gdk/wayland/Makefile.am | 21 ++- gdk/wayland/gdkdevice-wayland.c | 108 +++++++------- gdk/wayland/gdkdisplay-wayland.c | 8 +- gdk/wayland/gdkdisplay-wayland.h | 4 +- gdk/wayland/protocol/pointer-gestures.xml | 172 ---------------------- 6 files changed, 81 insertions(+), 236 deletions(-) delete mode 100644 gdk/wayland/protocol/pointer-gestures.xml diff --git a/configure.ac b/configure.ac index 32ae090012..ba40360209 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,7 @@ m4_define([cairo_required_version], [1.14.0]) m4_define([gdk_pixbuf_required_version], [2.30.0]) m4_define([introspection_required_version], [1.39.0]) m4_define([wayland_required_version], [1.5.91]) +m4_define([wayland_protocols_required_version], [1.0]) m4_define([mirclient_required_version], [0.11.0]) m4_define([mircookie_required_version], [0.17.0]) m4_define([epoxy_required_version], [1.0]) @@ -428,7 +429,7 @@ fi PKG_PROG_PKG_CONFIG -WAYLAND_DEPENDENCIES="wayland-client >= wayland_required_version xkbcommon >= 0.2.0 wayland-cursor >= wayland_required_version wayland-egl" +WAYLAND_DEPENDENCIES="wayland-client >= wayland_required_version wayland-protocols >= wayland_protocols_required_version xkbcommon >= 0.2.0 wayland-cursor >= wayland_required_version wayland-egl" if test "$enable_wayland_backend" = "maybe" ; then AC_PATH_PROG([WAYLAND_SCANNER],[wayland-scanner],[no]) PKG_CHECK_EXISTS($WAYLAND_DEPENDENCIES, [have_wayland_deps=yes], [have_wayland_deps=no]) @@ -444,6 +445,7 @@ fi if test "$enable_wayland_backend" = "yes"; then # For the cairo image backend cairo_backends="$cairo_backends cairo" + AC_SUBST(WAYLAND_PROTOCOLS_DATADIR, `$PKG_CONFIG --variable=pkgdatadir wayland-protocols`) GDK_BACKENDS="$GDK_BACKENDS wayland" GDK_WINDOWING="$GDK_WINDOWING #define GDK_WINDOWING_WAYLAND" diff --git a/gdk/wayland/Makefile.am b/gdk/wayland/Makefile.am index 93d099fb4c..187bcfbdef 100644 --- a/gdk/wayland/Makefile.am +++ b/gdk/wayland/Makefile.am @@ -20,8 +20,8 @@ noinst_LTLIBRARIES = \ libgdk-wayland.la BUILT_SOURCES = \ - pointer-gestures-client-protocol.h \ - pointer-gestures-protocol.c \ + pointer-gestures-unstable-v1-client-protocol.h \ + pointer-gestures-unstable-v1-protocol.c \ xdg-shell-client-protocol.h \ xdg-shell-protocol.c \ gtk-shell-client-protocol.h \ @@ -62,6 +62,22 @@ libgdkwaylandinclude_HEADERS = \ gdkwaylandselection.h \ gdkwaylandwindow.h +.SECONDEXPANSION: + +define protostability +$(shell echo $1 | sed 's/.*\(\\|\\).*/\1/') +endef + +define protoname +$(shell echo $1 | sed 's/\([a-z\-]\+\)-[a-z]\+-v[0-9]\+/\1/') +endef + +%-protocol.c : $(WAYLAND_PROTOCOLS_DATADIR)/$$(call protostability,$$*)/$$(call protoname,$$*)/$$*.xml + $(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@ + $(AM_V_GEN)$(SED) -i -e 's/WL_EXPORT //' $@ +%-client-protocol.h : $(WAYLAND_PROTOCOLS_DATADIR)/$$(call protostability,$$*)/$$(call protoname,$$*)/$$*.xml + $(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@ + %-protocol.c : $(srcdir)/protocol/%.xml $(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@ $(AM_V_GEN)$(SED) -i -e 's/WL_EXPORT //' $@ @@ -72,7 +88,6 @@ libgdkwaylandinclude_HEADERS = \ $(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@ EXTRA_DIST += \ - protocol/pointer-gestures.xml \ protocol/xdg-shell.xml \ protocol/gtk-shell.xml diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index fb452c9db4..c8f4d0840a 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -29,7 +29,7 @@ #include "gdkkeysyms.h" #include "gdkdeviceprivate.h" #include "gdkdevicemanagerprivate.h" -#include "pointer-gestures-client-protocol.h" +#include "pointer-gestures-unstable-v1-client-protocol.h" #include @@ -59,8 +59,8 @@ struct _GdkWaylandDeviceData struct wl_pointer *wl_pointer; struct wl_keyboard *wl_keyboard; struct wl_touch *wl_touch; - struct _wl_pointer_gesture_swipe *wl_pointer_gesture_swipe; - struct _wl_pointer_gesture_pinch *wl_pointer_gesture_pinch; + struct zwp_pointer_gesture_swipe_v1 *wp_pointer_gesture_swipe; + struct zwp_pointer_gesture_pinch_v1 *wp_pointer_gesture_pinch; GdkDisplay *display; GdkDeviceManager *device_manager; @@ -1808,12 +1808,12 @@ emit_gesture_swipe_event (GdkWaylandDeviceData *device, } static void -gesture_swipe_begin (void *data, - struct _wl_pointer_gesture_swipe *swipe, - uint32_t serial, - uint32_t time, - struct wl_surface *surface, - uint32_t fingers) +gesture_swipe_begin (void *data, + struct zwp_pointer_gesture_swipe_v1 *swipe, + uint32_t serial, + uint32_t time, + struct wl_surface *surface, + uint32_t fingers) { GdkWaylandDeviceData *device = data; GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display); @@ -1827,11 +1827,11 @@ gesture_swipe_begin (void *data, } static void -gesture_swipe_update (void *data, - struct _wl_pointer_gesture_swipe *swipe, - uint32_t time, - wl_fixed_t dx, - wl_fixed_t dy) +gesture_swipe_update (void *data, + struct zwp_pointer_gesture_swipe_v1 *swipe, + uint32_t time, + wl_fixed_t dx, + wl_fixed_t dy) { GdkWaylandDeviceData *device = data; @@ -1844,11 +1844,11 @@ gesture_swipe_update (void *data, } static void -gesture_swipe_end (void *data, - struct _wl_pointer_gesture_swipe *swipe, - uint32_t serial, - uint32_t time, - int32_t cancelled) +gesture_swipe_end (void *data, + struct zwp_pointer_gesture_swipe_v1 *swipe, + uint32_t serial, + uint32_t time, + int32_t cancelled) { GdkWaylandDeviceData *device = data; GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display); @@ -1912,12 +1912,12 @@ emit_gesture_pinch_event (GdkWaylandDeviceData *device, } static void -gesture_pinch_begin (void *data, - struct _wl_pointer_gesture_pinch *pinch, - uint32_t serial, - uint32_t time, - struct wl_surface *surface, - uint32_t fingers) +gesture_pinch_begin (void *data, + struct zwp_pointer_gesture_pinch_v1 *pinch, + uint32_t serial, + uint32_t time, + struct wl_surface *surface, + uint32_t fingers) { GdkWaylandDeviceData *device = data; GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display); @@ -1930,13 +1930,13 @@ gesture_pinch_begin (void *data, } static void -gesture_pinch_update (void *data, - struct _wl_pointer_gesture_pinch *pinch, - uint32_t time, - wl_fixed_t dx, - wl_fixed_t dy, - wl_fixed_t scale, - wl_fixed_t rotation) +gesture_pinch_update (void *data, + struct zwp_pointer_gesture_pinch_v1 *pinch, + uint32_t time, + wl_fixed_t dx, + wl_fixed_t dy, + wl_fixed_t scale, + wl_fixed_t rotation) { GdkWaylandDeviceData *device = data; @@ -1950,11 +1950,11 @@ gesture_pinch_update (void *data, } static void -gesture_pinch_end (void *data, - struct _wl_pointer_gesture_pinch *pinch, - uint32_t serial, - uint32_t time, - int32_t cancelled) +gesture_pinch_end (void *data, + struct zwp_pointer_gesture_pinch_v1 *pinch, + uint32_t serial, + uint32_t time, + int32_t cancelled) { GdkWaylandDeviceData *device = data; GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display); @@ -1996,13 +1996,13 @@ static const struct wl_touch_listener touch_listener = { touch_handle_cancel }; -static const struct _wl_pointer_gesture_swipe_listener gesture_swipe_listener = { +static const struct zwp_pointer_gesture_swipe_v1_listener gesture_swipe_listener = { gesture_swipe_begin, gesture_swipe_update, gesture_swipe_end }; -static const struct _wl_pointer_gesture_pinch_listener gesture_pinch_listener = { +static const struct zwp_pointer_gesture_pinch_v1_listener gesture_pinch_listener = { gesture_pinch_begin, gesture_pinch_update, gesture_pinch_end @@ -2046,21 +2046,21 @@ seat_handle_capabilities (void *data, if (wayland_display->pointer_gestures) { - device->wl_pointer_gesture_swipe = - _wl_pointer_gestures_get_swipe_gesture (wayland_display->pointer_gestures, - device->wl_pointer); - _wl_pointer_gesture_swipe_set_user_data (device->wl_pointer_gesture_swipe, - device); - _wl_pointer_gesture_swipe_add_listener (device->wl_pointer_gesture_swipe, - &gesture_swipe_listener, device); - - device->wl_pointer_gesture_pinch = - _wl_pointer_gestures_get_pinch_gesture (wayland_display->pointer_gestures, - device->wl_pointer); - _wl_pointer_gesture_pinch_set_user_data (device->wl_pointer_gesture_pinch, - device); - _wl_pointer_gesture_pinch_add_listener (device->wl_pointer_gesture_pinch, - &gesture_pinch_listener, device); + device->wp_pointer_gesture_swipe = + zwp_pointer_gestures_v1_get_swipe_gesture (wayland_display->pointer_gestures, + device->wl_pointer); + zwp_pointer_gesture_swipe_v1_set_user_data (device->wp_pointer_gesture_swipe, + device); + zwp_pointer_gesture_swipe_v1_add_listener (device->wp_pointer_gesture_swipe, + &gesture_swipe_listener, device); + + device->wp_pointer_gesture_pinch = + zwp_pointer_gestures_v1_get_pinch_gesture (wayland_display->pointer_gestures, + device->wl_pointer); + zwp_pointer_gesture_pinch_v1_set_user_data (device->wp_pointer_gesture_pinch, + device); + zwp_pointer_gesture_pinch_v1_add_listener (device->wp_pointer_gesture_pinch, + &gesture_pinch_listener, device); } g_signal_emit_by_name (device_manager, "device-added", device->pointer); diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 64529fb32c..287662b88f 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -35,7 +35,7 @@ #include "gdkkeysprivate.h" #include "gdkprivate-wayland.h" #include "gdkglcontext-wayland.h" -#include "pointer-gestures-client-protocol.h" +#include "pointer-gestures-unstable-v1-client-protocol.h" /** * SECTION:wayland_interaction @@ -358,12 +358,12 @@ gdk_registry_handle_global (void *data, display_wayland->subcompositor = wl_registry_bind (display_wayland->wl_registry, id, &wl_subcompositor_interface, 1); } - else if (strcmp (interface, "_wl_pointer_gestures") == 0 && - version == GDK__WL_POINTER_GESTURES_VERSION) + else if (strcmp (interface, "zwp_pointer_gestures_v1") == 0 && + version == GDK_ZWP_POINTER_GESTURES_V1_VERSION) { display_wayland->pointer_gestures = wl_registry_bind (display_wayland->wl_registry, - id, &_wl_pointer_gestures_interface, version); + id, &zwp_pointer_gestures_v1_interface, version); } else handled = FALSE; diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h index 4156bc6288..0fb87eefd5 100644 --- a/gdk/wayland/gdkdisplay-wayland.h +++ b/gdk/wayland/gdkdisplay-wayland.h @@ -45,7 +45,7 @@ G_BEGIN_DECLS #define GDK_WAYLAND_MAX_THEME_SCALE 2 #define GDK_WAYLAND_THEME_SCALES_COUNT GDK_WAYLAND_MAX_THEME_SCALE -#define GDK__WL_POINTER_GESTURES_VERSION 1 +#define GDK_ZWP_POINTER_GESTURES_V1_VERSION 1 typedef struct _GdkWaylandSelection GdkWaylandSelection; @@ -73,7 +73,7 @@ struct _GdkWaylandDisplay struct wl_input_device *input_device; struct wl_data_device_manager *data_device_manager; struct wl_subcompositor *subcompositor; - struct _wl_pointer_gestures *pointer_gestures; + struct zwp_pointer_gestures_v1 *pointer_gestures; GList *async_roundtrips; diff --git a/gdk/wayland/protocol/pointer-gestures.xml b/gdk/wayland/protocol/pointer-gestures.xml deleted file mode 100644 index 1bca8f7ed2..0000000000 --- a/gdk/wayland/protocol/pointer-gestures.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - - A global interface to provide semantic touchpad gestures for a given - pointer. - - Two gestures are currently supported: swipe and zoom/rotate. - All gestures follow a three-stage cycle: begin, update, end and - are identified by a unique id. - - Warning! The protocol described in this file is experimental. Each - version of this protocol should be considered incompatible with any - other version, and a client binding to a version different to the one - advertised will be terminated. Once the protocol is declared stable, - compatibility is guaranteed, the '_' prefix will be removed from the - name and the version will be reset to 1. - - - - - Create a swipe gesture object. See the - wl_pointer_gesture_swipe interface for details. - - - - - - - - Create a pinch gesture object. See the - wl_pointer_gesture_pinch interface for details. - - - - - - - - - A swipe gesture object notifies a client about a multi-finger swipe - gesture detected on an indirect input device such as a touchpad. - The gesture is usually initiated by multiple fingers moving in the - same direction but once initiated the direction may change. - The precise conditions of when such a gesture is detected are - implementation-dependent. - - A gesture consists of three stages: begin, update (optional) and end. - There cannot be multiple simultaneous pinch or swipe gestures on a - same pointer/seat, how compositors prevent these situations is - implementation-dependent. - - A gesture may be cancelled by the compositor or the hardware. - Clients should not consider performing permanent or irreversible - actions until the end of a gesture has been received. - - - - - - - - - This event is sent when a multi-finger swipe gesture is detected - on the device. - - - - - - - - - - This event is sent when a multi-finger swipe gesture changes the - position of the logical center. - - The dx and dy coordinates are relative coordinates of the logical - center of the gesture compared to the previous event. - - - - - - - - - This event is sent when a multi-finger swipe gesture ceases to - be valid. This may happen when one or more finger is lifted or - the gesture is cancelled. - - When a gesture is cancelled, the client should undo state changes - caused by this gesture. What causes a gesture to be cancelled is - implementation-dependent. - - - - - - - - - - A pinch gesture object notifies a client about a multi-finger pinch - gesture detected on an indirect input device such as a touchpad. - The gesture is usually initiated by multiple fingers moving towards - each other or away from each other, or by two or more fingers rotating - around a logical center of gravity. The precise conditions of when - such a gesture is detected are implementation-dependent. - - A gesture consists of three stages: begin, update (optional) and end. - There cannot be multiple simultaneous pinch or swipe gestures on a - same pointer/seat, how compositors prevent these situations is - implementation-dependent. - - A gesture may be cancelled by the compositor or the hardware. - Clients should not consider performing permanent or irreversible - actions until the end of a gesture has been received. - - - - - - - - - This event is sent when a multi-finger pinch gesture is detected - on the device. - - - - - - - - - - This event is sent when a multi-finger pinch gesture changes the - position of the logical center, the rotation or the relative scale. - - The dx and dy coordinates are relative coordinates in the - surface coordinate space of the logical center of the gesture. - - The scale factor is an absolute scale compared to the - pointer_gesture_pinch.begin event, e.g. a scale of 2 means the fingers - are now twice as far apart as on pointer_gesture_pinch.begin. - - The rotation is the relative angle in degrees clockwise compared to the previous - pointer_gesture_pinch.begin or pointer_gesture_pinch.update event. - - - - - - - - - - - This event is sent when a multi-finger pinch gesture ceases to - be valid. This may happen when one or more finger is lifted or - the gesture is cancelled. - - When a gesture is cancelled, the client should undo state changes - caused by this gesture. What causes a gesture to be cancelled is - implementation-dependent. - - - - - - - -- 2.30.2